home *** CD-ROM | disk | FTP | other *** search
- REM ZBasic Dialog Example
- REM ©MacTutor 1987
- REM By Dave Kelly
- WINDOW OFF:REM Always use this as first line of program to prevent default window from being created
- COORDINATE WINDOW:REM Set window to Macintosh coordinate system
- False=0:True=NOT False
- IF PEEK(&28E) AND 128 THEN Wtype=1 ELSE Wtype=9
- Wtype=1:REM Due to Bugs in ZBasic 3.02 Zoom window will not be used.
- MENU 1,0,1,"File"
- MENU 1,1,1,"Quit"
- DIALOG OFF
- WINDOW 1,"Window 1",(10,50)-(250,200),Wtype
- TEXT 4,9,0,0
- BUTTON 1,1,"Button 1",(20,20)-(100,50)
- BUTTON 2,1,"Button 2",(20,60)-(100,90)
- WINDOW 2,"Window 2",(275,50)-(500,200),Wtype
- TEXT 4,9,0,0
- EDIT FIELD 1,"",(10,10)-(100,35),1,1
- EDIT FIELD 2,"",(10,40)-(100,65),1,1
- WINDOW 3,"Dialog Event (Window #3)",(10,250)-(500,340),28
- TEXT 4,9,0,0
- ON DIALOG GOSUB "DialogEvent"
- ON BREAK GOSUB "BreakEvent"
- ON MENU GOSUB "MenuEvent"
- DIALOG ON:BREAK ON:MENU ON
- "Mainloop":DO:D=DIALOG(0):IF D>0 THEN GOSUB "DEvent"
- UNTIL D=0
- GOTO "Mainloop"
- "MenuEvent"
- DIALOG STOP:
- Menunumber=MENU(0):Itemnumber=MENU(1)
- IF Menunumber=1 AND Itemnumber=1 THEN END
- DIALOG ON
- RETURN
- "BreakEvent"
- STOP
- "DialogEvent"
- D = DIALOG(0):REM check to see what event occured
- "DEvent"
- DIALOG STOP
- Currentwindow = WINDOW(0)
- Windowselection = WINDOW(1)
- WINDOW OUTPUT 3
- IF D = 1 GOSUB "Buttonevent"
- IF D = 2 GOSUB "EditEvent"
- IF D = 3 GOSUB "InactiveWindow"
- IF D = 4 GOSUB "Closebox"
- IF D = 5 GOSUB "Refresh"
- IF D = 6 GOSUB "Returnkey"
- IF D = 7 GOSUB "Tabkey"
- IF D = 8 GOSUB "Zoomin"
- IF D = 9 GOSUB "Zoomout"
- IF D =10 GOSUB "Shifttab"
- IF D =11 GOSUB "Clearkey"
- IF D =12 GOSUB "LeftArrow"
- IF D =13 GOSUB "RightArrow"
- IF D =14 GOSUB "UpArrow"
- IF D =15 GOSUB "DownArrow"
- IF D =16 GOSUB "Keypress"
- PRINT @(50,3) "DIALOG(0) : ";D
- PRINT @(50,4) "Active Window #";Currentwindow
- PRINT @(50,5) "Output Window #";Windowselection
- WINDOW OUTPUT Outwindow:WINDOW Windowselection
- DIALOG ON
- RETURN
- "Buttonevent"
- Buttonclicked=DIALOG(1)
- Bstatus=BUTTON(Buttonclicked):BUTTON Buttonclicked,3-Bstatus
- PRINT@(1,1) "Button clicked : ";Buttonclicked
- RETURN
- "EditEvent":
- EditField=DIALOG(2)
- PRINT@(1,2) "Edit Field : ";EditField
- RETURN
- "InactiveWindow"
- Windowselection=DIALOG(3)
- PRINT@(1,3) "Inactive Window : ";Windowselection
- RETURN
- "Closebox":
- ClosedWindow=DIALOG(4)
- IF ClosedWindow=3 THEN END
- PRINT@(1,4) "Closed Window : ";ClosedWindow
- RETURN
- "Refresh":
- ErasedWindow=DIALOG(5)
- PRINT @(1,5) "Erased Window : ";ErasedWindow
- RETURN
- "Returnkey":
- Returnpress=DIALOG(6)
- PRINT @(25,1) "Return press : ";Returnpress
- RETURN
- "Tabkey":
- Tabpress=DIALOG(7)
- PRINT @(25,2) "Tab press : ";Tabpress
- RETURN
- "Zoomin": REM NEW ROMS ONLY
- Zin=DIALOG(8)
- WINDOW Zin
- PRINT@(1,1) "Thank you for zooming in window";Zin
- PRINT @(25,3) "Zoom in window : ";Zin
- RETURN
- "Zoomout":
- Zout=DIALOG(9)
- WINDOW Zout
- PRINT@(1,1)"Thank you for zooming out window";Zout
- PRINT @(25,4) "Zoom out window : ";Zout
- RETURN
- "Shifttab":
- CurrentEdit=DIALOG(10)
- PRINT @(25,5) "Current Edit Field:";CurrentEdit
- RETURN
- "Clearkey":
- CurrentEdit=DIALOG(11)
- PRINT @(25,5) "Current Edit Field:";CurrentEdit
- RETURN
- "LeftArrow":
- CurrentEdit=DIALOG(12)
- PRINT @(25,5) "Current Edit Field:";CurrentEdit
- RETURN
- "RightArrow":
- CurrentEdit=DIALOG(13)
- PRINT @(25,5) "Current Edit Field:";CurrentEdit
- RETURN
- "UpArrow":
- CurrentEdit=DIALOG(14)
- PRINT @(25,5) "Current Edit Field:";CurrentEdit
- RETURN
- "DownArrow":
- CurrentEdit=DIALOG(15)
- PRINT @(25,5) "Current Edit Field:";CurrentEdit
- RETURN
- "Keypress":
- ASCIIkey=DIALOG(16)
- PRINT @(50,1) "ASCII key pressed :";ASCIIkey;" "
- PRINT @(75,1) " ":PRINT @(75,1) CHR$(ASCIIkey)
- RETURN
- END
-